package com.usian.exception;


import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

//@ControllerAdvice
public class BaseExceptionHandler {

    @ExceptionHandler(NullPointerException.class)
    @ResponseBody
    public String error(NullPointerException e){
        System.out.println("调用了公共异常处理类");
        return "出现了空指针异常！";
    }

    @ExceptionHandler(ArithmeticException.class)
    @ResponseBody
    public String error2(ArithmeticException e){
        System.out.println("调用了公共异常处理类");
        return "出现了算数异常！";
    }


    @ExceptionHandler(Exception.class)
    @ResponseBody
    public String error3(Exception e){
        System.out.println("调用了公共异常处理类");
        return "出现了全局异常！";
    }
}
